/*
 * @Author: yangzonglong
 * @Date: 2021-07-06 16:08:35
 * @version: v1.0.0
 * @Descripttion: table config
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-11-29 16:06:11
 * @Auditor:
 */

import Input from './input/Input';
import Text from './text/Text';
import InputNumber from './inputNumber/InputNumber';
import TextArea from './textArea/Textarea';
import Radio from './radio/Radio';
import Checkbox from './checkbox/Checkbox';
import DatePicker from './datePicker/DatePicker';
import DataLinkLov from './dataLinkLov/DataLinkLov';
import DataLinkComBox from './dataLinkComBox/DataLinkComBox';
import Select from './select/Select';
import Code from './code/Code';
import Upload from './upload/Upload';
import Switch from './switch/Switch';
import StatusTransfer from './statusTransfer/StatusTransfer';
import FormFiled from './formFiled/FormFiled';

import { ColumnType as AntdColumnType } from 'antd/lib/table/interface';
import { TableProps as AntdTableProps } from 'antd/lib/table';

import RadioController from './radio/RadioController';
import CheckboxController from './checkbox/CheckboxController';
import InputController from './input/InputController';
import TextController from './text/TextController';
import InputNumberController from './inputNumber/InputNumberController';
import TextAreaController from './textArea/TextAreaController';
import DatePickerController from './datePicker/DatePickerController';
import DataLinkLovController from './dataLinkLov/DataLinkLovController';
import DataLinkComBoxController from './dataLinkComBox/DataLinkComBoxController';
import SelectController from './select/SelectController';
import CodeController from './code/CodeController';
import UploadController from './upload/UploadController';
import StatusTransferController from './statusTransfer/StatusTransferController';
import FormFiledController from './formFiled/FormFiledController';
import SwitchController from './switch/SwitchController';
export interface DataItemProps {
  id: string;
  _isCreate?: boolean;
  _isEdit?: boolean;
  _isImport?: boolean;
  [prop: string]: any;
}

export interface ColumnType extends AntdColumnType<DataItemProps> {
  type: string; // 子控件类型
  originalIndex?: number; // 子控件索引
  options?: any; // 子控件配置项
  [props: string]: any;
}

export interface TableProps extends AntdTableProps<DataItemProps> {
  initialValue?: string;
  btnGroup?: any[];
  bacthUploadData: boolean | undefined;
  columns: ColumnType[];
  showItemNo: boolean;
  showBigTitle?: boolean;
  bigTitle?: boolean;
  itemNoWidth?: number;
  name?: string;
}

export interface IProps {
  tableProps?: any;
  isInitialValue?: boolean; // 可选择项
  initialValue?: string; // 可选择项
  initialValueEn?: string; // 可选择项
  initialValues?: string; // 可选择项
  placeholder?: string;
  placeholderEn?: string;
  checkRule?: string;
  text?: string;
  dataIndex?: string;
  title?: string;
  titleEn?: string;
  format?: string;
  accept?: string;
  textAlign?: string;
  bindName?: string;
  formName?: string;
  bacthUploadData?: boolean;
  originalIndex?: number;
  itemNoWidth?: number;
  precision?: number;
  maxCount?: number;
  print?: boolean;
  hideInput?: boolean;
  disabled?: boolean;
  exportFlag?: boolean;
  printType?: boolean;
  statusTransfer?: string;
  statusTransferEn?: string;
  step?: number;
  max?: number;
  min?: number;
  formatterMoney?: boolean;
  hideArrow?: boolean;
  width?: number | string;
  showFiled?: string;
  showItemNo?: boolean;
  required?: boolean;
  columns?: ColumnType[];
  dataSource?: any[];
  actionText?: string;
  scriptText?: string;
  fontSize?: number;
  fontWeight?: number;
  backgroundColor?: string;
  color?: string;
  customizeStyleFlag?: boolean;
  uploadUrl?: string;
  downloadUrl?: string;
  downloadScript?: string;
  setCurColumn?(column: ColumnType): void;
  changeColumnOptions(k: string, v: any, originalIndex?: number): void;
  changeControlProps(k: string, value: any, mergeOptions?: boolean): void;
}

export const menus = [
  { text: '文本', controlType: 'text' },
  { text: '单行输入', controlType: 'input' },
  { text: '数字', controlType: 'inputNum' },
  { text: '多行文本', controlType: 'textArea' },
  { text: '单项选择', controlType: 'radio' },
  { text: '多项选择', controlType: 'checkbox' },
  { text: '下拉选择', controlType: 'select' },
  { text: '日期', controlType: 'datePicker' },
  { text: 'Lov关联', controlType: 'dataLink' },
  { text: 'Combox关联', controlType: 'dataLinkCombox' },
  { text: '码', controlType: 'code' },
  { text: '附件上传', controlType: 'upload' },
  { text: '状态转换文字', controlType: 'statusTransfer' },
  { text: '切换', controlType: 'switch' },
  { text: '表单/脚本', controlType: 'formFiled' },
];

export const ControlMap = {
  radio: Radio,
  input: Input,
  text: Text,
  textArea: TextArea,
  checkbox: Checkbox,
  datePicker: DatePicker,
  dataLink: DataLinkLov,
  dataLinkCombox: DataLinkComBox,
  select: Select,
  inputNum: InputNumber,
  code: Code,
  upload: Upload,
  statusTransfer: StatusTransfer,
  formFiled: FormFiled,
  switch: Switch,
};

export const ControllerMap = {
  radio: RadioController,
  checkbox: CheckboxController,
  input: InputController,
  text: TextController,
  textArea: TextAreaController,
  datePicker: DatePickerController,
  dataLink: DataLinkLovController,
  dataLinkCombox: DataLinkComBoxController,
  select: SelectController,
  inputNum: InputNumberController,
  code: CodeController,
  upload: UploadController,
  statusTransfer: StatusTransferController,
  formFiled: FormFiledController,
  switch: SwitchController,
};
